package com.woniu.woniuk16.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;

@Configuration
public class MyRedisConfig {


    @Bean("rtl")
    public RedisTemplate<String,Object> getRedis(RedisConnectionFactory connectionFactory){
        RedisTemplate<String, Object> sort = new RedisTemplate<>();
        sort.setKeySerializer(RedisSerializer.string());
        sort.setHashKeySerializer(RedisSerializer.string());
        sort.setValueSerializer(RedisSerializer.json());
        sort.setHashValueSerializer(RedisSerializer.json());
        sort.setConnectionFactory(connectionFactory);
        sort.afterPropertiesSet();
        return sort;
    }
}
